/*
 * CsvThermistorTableReader.hpp
 *
 * Copyright 2012 Pieter Agten
 *
 * This file is part of tltgen.
 *
 * tltgen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * tltgen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with tltgen.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   CsvThermistorTableReader.hpp
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   12 feb 2013
 */

#ifndef CSVTHERMISTORTABLEREADER_HPP
#define CSVTHERMISTORTABLEREADER_HPP

#include "ThermistorTableRow.hpp"

#include "ThermistorTableReader.hpp"

using boost::shared_ptr;

namespace tltgen {

  class Circuit;
  class AnalogToDigitalConverter;
  class ThermistorTable;
  class TemperatureScale;
  class CsvThermistorTableReader : public ThermistorTableReader {
  public:
    CsvThermistorTableReader(unsigned int temperatureColumn, unsigned int otherColumn, 
			     ThermistorTableRow::Column otherColumnType, const shared_ptr<TemperatureScale>& temperatureScale, 
			     const shared_ptr<Circuit>& circuit, const shared_ptr<AnalogToDigitalConverter>& analogToDigitalConverter,
			     unsigned int nbLinesToSkip = 0, char separator = ',');

    static bool isValidColumns(unsigned int temperatureColumn, unsigned int otherColumn);
    static bool isValidOtherColumnType(ThermistorTableRow::Column otherColumnType);
    static bool isValidTemperatureScale(const shared_ptr<TemperatureScale>& temperatureScale);
    static bool isValidCircuit(const shared_ptr<Circuit>& circuit);
    static bool isValidAnalogToDigitalConverter(const shared_ptr<AnalogToDigitalConverter>& adc);
    static bool isValidNbLinesToSkip(unsigned int value);
    static bool isValidSeparator(char value);

    virtual unsigned int getTemperatureColumn() const;
    virtual unsigned int getOtherColumn() const;
    virtual ThermistorTableRow::Column getOtherColumnType() const;
    virtual shared_ptr<TemperatureScale> getTemperatureScale() const;
    virtual shared_ptr<Circuit> getCircuit() const;
    virtual shared_ptr<AnalogToDigitalConverter> getAnalogToDigitalConverter() const;
    virtual unsigned int getNbLinesToSkip() const;
    virtual char getSeparator() const;

    virtual shared_ptr<ThermistorTable> read(std::istream& in) const;

  protected:
    const unsigned int temperatureColumn;
    const unsigned int otherColumn;
    const ThermistorTableRow::Column otherColumnType;
    const shared_ptr<TemperatureScale> temperatureScale;
    const shared_ptr<Circuit> circuit;
    const shared_ptr<AnalogToDigitalConverter> analogToDigitalConverter;
    const unsigned int nbLinesToSkip;
    const char separator;

  };

}

#endif
